<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<script type="text/javascript">
	//文本框
	var editor;
	$(function() {
		editor = $("#seckillcontentUpdate")
				.xheditor(
						{
							tools : 'Removeformat,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Align,Emot,Img,Link',
							skin : 'default',
							showBlocktag : false,//段落标签
							internalScript : false,
							internalStyle : false,
							width : 580,
							height : 200,
							fullscreen : false,
							forcePtag : true,
							cleanPaste : 1,
							upMultiple : 1,
							html5Upload : false,
							upImgUrl : "",
							upImgExt : 'jpg,jpeg,gif,png',
							onUpload : insertUpload
						//指定回调函数
						});
		//	$("#seckillcontent").focus();
		$("#seckill_type_query").val("${seckillType}");//初始化类别下拉框
	});
	
	//时间数据表
	function addSecKillTimeButton() {

		$("#seckill_item1").append(
				"<div class='seckillTime'><div>----------------------------------------------------</div><a onclick='javascript:moveseckillTime(this);' style=\"cursor: pointer;\">[删除]</a><div><input type='text' id='startTime' value='" + $("#calendar_start_time1").val()
				+ "'>开始时间</div><div><input type='text' id='endTime' value='" + $("#calendar_end_time1").val()
				+ "'>结束时间</div><div><input type='text' id='numberChange' value='" + $("#count1").val() + "'>剩余数量<font color=\"red\">[日常活动]</font></div><div><input type='text' id='number' value='" + $("#count1").val() + "'>默认数量<font color=\"red\">[日常活动]</font></div></div>");
		$("#calendar_start_time1").val("");
		$("#calendar_end_time1").val("");
		$("#count1").val("");
	}
	
	 //更新秒杀活动
	function updateSeckillWeb(id){
		 
		 
		 
		var secKillTimeList = new Array();
		$(".seckillTime").each(function() {
			 //alert($(this).find("#startTime").val());
			//alert($(this).find("#endTime").val());
			//alert($(this).find("#number").val()); 
			secKillTimeList.push({
				"startTime":$(this).find("#startTime").val(),
				"endTime":$(this).find("#endTime").val(),
				"customCount":$(this).find("#number").val(),
				"count":$(this).find("#numberChange").val()
				
			});
		});
	
		$.post("updateSeckillWeb.cms",{
			identifier:id,
			title:$("#title1").val(), 
			buttonName:$("#buttonName1").val(),
			seckillcontentUpdate:$("#seckillcontentUpdate").val(),
			secKillTimeList : $.toJSON(secKillTimeList),
			validateMsg:$("#validateMsg1").val(),
			picUrl:	$("#seckillPicUrl1").val(),
			seckillType: $("#seckill_type_query").val(),
			startDate:$("#calendar_start_date").val(),
			endDate:$("#calendar_end_date").val()
		},function(data){
			if(data=='success'){
				$("#content_detail").load("seckillList.cms");
			}
		});	
	} 
	function seckillUploadImg(){
		var filepath=$("#uploadImgseckill1").val(); 
		var extStart=filepath.lastIndexOf("."); 
		var ext=filepath.substring(extStart,filepath.length).toUpperCase(); 
		if(ext!=".PNG"&&ext!=".JPG"&&ext!=".JPEG"&&ext!=".GIF"){ 
			alert("图片限于png,jpeg,jpg,gif格式"); 
			return ; 
		}
		$("#seckill_upload_img_form1").ajaxSubmit({
			dataType : 'json',
			cache : false,
			success : function(data) {
				$("#seckillPicUrl1").val(data.pictureUrl);
				
				 if(data.pictureUrl!=""){
					 alert("上传图片成功");
				}else{
					alert("上传图片失败");
					
				}
			},
			error : function(err) {
				alert(err);
			}
		});
		return false;
	}
</script>

<strong style="font-size: 15px; color: red;">日常活动-修改活动页面</strong>
<table border="1">
          <tr>
			<td>活动类型：</td>
			<td><select id="seckill_type_query">
                <option value="01">精彩活动</option>
                 <option value="02">试手气</option>
                </select>
			</td>
		</tr>
	<tr>
		<td>秒杀标题：</td>
		<td><input type="text" name="title1" id="title1"
			value="${seckill.title}" /></td>
	</tr>
	<tr>
		<td>按键名称：</td>
		<td><input type="text" name="buttonName1" id="buttonName1"
			value="${seckill.buttonName}" /></td>
	</tr>
	<tr>
		<td>活动内容：</td>
		<td><textarea id="seckillcontentUpdate" name="seckillcontentUpdate">${seckill.body}</textarea>
		</td>
	</tr>
	<tr>
		<td>图片：<input type="hidden" id="seckillPicUrl1"
			name="seckillPicUrl1" value="${seckill.picUrl}" /></td>
		<td>
			<div class="type-file-box">
				<form id="seckill_upload_img_form1" enctype="multipart/form-data"
					method="post" action="seckillUploadImg.cms">
					<input type="file" id="uploadImgseckill1" name="uploadImgseckill1"
						onchange="seckillUploadImg();return false;">

				</form>
			</div>
		
		</td>
	</tr>
	
	<tr id="seckillDate">
	<td><font color="red">[日常活动]</font>秒杀日期：</td>
	 <td >
				<div style="top: 300px; left: 220px;">
					<div class="h_timeCreate_Input02">
						开始日期<input
							onClick="WdatePicker({el:'calendar_start_date',dateFmt:'yyyy-MM-dd'});"
							type="text" id="calendar_start_date" name="startDate" value="${seckill.startDate}" />
					</div>
					<div class="h_timeCreate_Input02">
						结束日期<input
							onClick="WdatePicker({el:'calendar_end_date',dateFmt:'yyyy-MM-dd'});"
							type="text" id="calendar_end_date" name="endDate" value="${seckill.endDate}"/>
					</div>
				</div>
		
	</td>
	</tr>
	
	<tr id="seckillDateSec" >
	<td><font color="red">[日常活动]</font>秒杀时间：</td>
		<td>
			<div style="top: 300px; left: 220px;">
					<div class="h_timeCreate_Input02">
						具体开始时间<input
							onClick="WdatePicker({el:'calendar_start_time1',dateFmt:'HH:mm:ss'});"
							type="text" id="calendar_start_time1" name="startTime" value="" />
					</div>
					<div class="h_timeCreate_Input02">
						具体结束时间<input
							onClick="WdatePicker({el:'calendar_end_time1',dateFmt:'HH:mm:ss'});"
							type="text" id="calendar_end_time1" name="endTime" />
					</div>
			</div>
		</td>
	</tr>
	<tr>
		<td >产品数量：</td>
		<td><input type="text" name="count1" id="count1" value="1"/></td>
	</tr>
	<tr>
		<td colspan="2" style="text-align: center;"><button
				style="width: 100px; height: 20px;" onclick="addSecKillTimeButton()">添加秒杀</button>
		</td>
	</tr>
	<tr>
		<td style="height: 150px">秒杀数据列表：</td>
		<td style="height: 150px" id="seckill_item1"><c:forEach
				items="${seckill.seckillTimeList}" var="seckillTime">

				<div class="seckillTime">
				<div>----------------------------------------------------</div>
				<a onclick='javascript:moveseckillTime(this);' style="cursor: pointer;">[删除]</a>
					<div>
						<input type="text" id="startTime"
							value="${seckillTime.startTime}">开始时间

					</div>
					<div>
						<input type="text" id="endTime"
							value="${seckillTime.endTime}">结束时间
					</div>
					<div>
						<input type="text" id="numberChange" value="${seckillTime.count}">剩余数量<font color="red">[日常活动]</font>
					</div>
					<div>
						<input type="text" id="number" value="${seckillTime.customCount}">默认数量<font color="red">[日常活动]</font>
					</div>
				</div>
			</c:forEach></td>
	</tr>
	<tr>
		<td>手机验证信息：</td>
		<td><input type="text" name="validateMsg1" id="validateMsg1"
			value="${seckill.validateMsg}" /></td>
	</tr>
	<tr>
		<td></td>
		<td><button onclick="updateSeckillWeb('${seckill.identifier}')">修改确认</button>
			<button onclick="closedUpadteSeckill()">取消</button></td>

	</tr>
</table>

